package comment

import (
	models "HeadLineNews/proto_models/app/comment_model"
	"HeadLineNews/utils"
	"github.com/gin-gonic/gin"
)

type Ctx interface {
	ParseParamUserComment(c *gin.Context) (p *models.RequestUserComment, err error)
	ParseParamRetrieveNewsComment(c *gin.Context) (p *models.RequestRetrieveNewsComment, err error)
	ParseParamRetrieveNewsFloorComment(c *gin.Context) (p *models.RequestRetrieveNewsFloorComment, err error)
}

type ctx struct {
}

func NewCtx() Ctx {
	return &ctx{}
}

// ParseParamUserComment 解析用户评论的参数
func (ctx *ctx) ParseParamUserComment(c *gin.Context) (p *models.RequestUserComment, err error) {
	p = new(models.RequestUserComment)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamRetrieveNewsComment 解析请求某条新闻的参数
func (ctx *ctx) ParseParamRetrieveNewsComment(c *gin.Context) (p *models.RequestRetrieveNewsComment, err error) {
	p = new(models.RequestRetrieveNewsComment)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamRetrieveNewsFloorComment 解析请求某条新闻的某一层楼评论的参数
func (ctx *ctx) ParseParamRetrieveNewsFloorComment(c *gin.Context) (p *models.RequestRetrieveNewsFloorComment, err error) {
	p = new(models.RequestRetrieveNewsFloorComment)
	err = utils.ShouldBindProtobuf(c, p)
	return
}